﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebComponents.Data;
using WebComponents;
using GBIT.Web;
using System.Collections.Generic;

public partial class Admincp_Default : System.Web.UI.Page {
  protected void Page_Load(object sender, EventArgs e) {
    int cid = ConvertType.ToInt(Request.Params["cid"]);
    int tabid = ConvertType.ToInt(Request.Params["tabid"]);
    MenuInfo menu = null;
    if (cid > 0)
      menu = MenuController.GetById(cid, StatusType.All);
    else {
      if (ConvertType.ToString(Request.Params["mod"]) != "") {
        menu = new MenuInfo(); //MenuController.GetByURL(ConvertType.ToString(Request.Params["mod"]));
        menu.MenuUrl = "Controls/" + ConvertType.Decode(ConvertType.ToString(Request.Params["mod"]));
      } else
        if (tabid > 0)
          menu = MenuController.GetById(tabid, StatusType.IsActive);
        else {
          List<MenuInfo> menuLevel1 = MenuController.GetMenuLevel1(StatusType.IsActive);
          if (menuLevel1.Count > 0) {
            if (menuLevel1[0].MenuUrl.EndsWith(".ascx"))
              menu = menuLevel1[0];
          }
        }
    }
    if (menu != null && menu.MenuUrl.EndsWith(".ascx")) {
      Control control = Page.LoadControl(menu.MenuUrl);
      if (control is UserControlBase)
        Session["CurrentControl"] = control;
      else
        Session["CurrentControl"] = null;
      placeContent.Controls.Add(control);
    } else
      Session["CurrentControl"] = null;
  }
}
